﻿using System;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace BizElements.BusinessLayer
{
    /// <summary>Writes to log via remoting service.</summary>
    public class LogReceiverService : ILogReceiverService
    {
        /// <summary>Writes <b>LogEntry</b>.</summary>
        /// <param name="serializedLogEntry">Binary serialized <b>LogEntry</b> object.</param>
        public virtual void WriteLogEntry(byte[] serializedLogEntry)
        {
            try
            {
                LogEntry logEntry = (LogEntry)Serializer.DeserializeWithBinaryFormater(serializedLogEntry);
                Logger.Write(logEntry);
            }
            catch (Exception e)
            {
                MethodReceiverService.LogError(e);
            }
        }
    }
}
